package com.uniledger.exchange.login.fragment;

import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.uniledger.exchange.base.fragment.BaseFragment;

public abstract class SignUpFragment extends BaseFragment implements View.OnClickListener{

    protected SignUpListener upListener;

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        if (upListener!=null){
            upListener.getButton().setOnClickListener(this);
        }
    }

    public void onButtonPressed(Uri uri) {
        if (upListener != null) {
            upListener.press(uri);
        }
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        if (context instanceof SignUpListener) {
            upListener = (SignUpListener) context;
        } else {
            throw new RuntimeException(context.toString()
                    + " must implement OnBackupListener");
        }
    }

    @Override
    public void onDetach() {
        super.onDetach();
        upListener = null;
    }


}
